import { Context } from 'koa';
import config from '../../config';

export default class OrderController {
    
	/**
	 * 获取商品订单号
	 */
    static async getOrderNo(ctx: Context, next: () => Promise<any>) {
        const data = ctx.request.body;
        let order = {
            orderNum: '00001',
            cpId: 'cp-0001',
            amount: data.amount,
            uri: 'http://139.196.218.92:4213/recharge'
        }
        
        config.a = data.amount;
        ctx.result = { success: true, message: '订单生成！', data: order };
        ctx.status = 200;
        next();
    }
	/**
	 * 商品订单详情
	 */
    static async chankOrder(ctx: Context, next: () => Promise<any>) {
        const data = ctx.request.body;
        
        let order = {
            amount: config.a || 100,
            appkey: 'app001',
            app_id: '001',
            cpImg: 'fx-pica1.2344.com/g4/2/allimg/120617/320_061F04H5C25.jpg',
            platform: 'http://139.196.218.92:4212/dist/popstar.html',
            gameName: '拯救星星',
            cpName: '大插头'
        }
        ctx.result = { success: true, message: '订单详情', data: order };
        ctx.status = 200;
        next();
    }
	/**
	 * 支付商品订单
	 */
    static async payOrder(ctx: Context, next: () => Promise<any>) {
        const data = ctx.request.body;
        let order = {
            orderNum: '00001',
        }
        ctx.result = { success: true, message: '订单详情', data: order };
        ctx.status = 200;
        next();
    }
}